<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <script>
        function getAge() {
            var now = new Date().getFullYear();
            return now - this.birth;
        }
        var zhourui = {
            name: "zhourui",
            birth: 1997,
            age: getAge
        };
        //下面在console中, 输出都为23
        getAge.apply(zhourui, []);//注意这里的this.birth指向了zhourui
        //[]代表空参, 我们通过apply函数来给getAge中的this指定了对象
        getAge.apply(zhourui, []);
    </script>
</body>
</html>